package com.example.fitnessapp.controller;


import com.example.fitnessapp.util.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/pk")
@RequiredArgsConstructor
public class PKController {
    @PostMapping("/start")
    public ApiResponse<Map<String, String>> startPk(@RequestBody Map<String, String> req) {
        Map<String, String> res = new HashMap<>();
        res.put("pkId", "pk001");
        return ApiResponse.ok("PK发起成功", res);
    }

    @GetMapping("/rank/{pkId}")
    public ApiResponse<List<Map<String, Object>>> pkRank(@PathVariable String pkId) {
        List<Map<String, Object>> rank = new ArrayList<>();
        Map<String, Object> p1 = new HashMap<>();
        p1.put("userId", "10001");
        p1.put("nickname", "张三");
        p1.put("score", 12345);
        rank.add(p1);
        Map<String, Object> p2 = new HashMap<>();
        p2.put("userId", "10002");
        p2.put("nickname", "李四");
        p2.put("score", 11000);
        rank.add(p2);
        return ApiResponse.ok("success", rank);
    }
}
